<template>
  <!-- 新增窗口 -->
  <a-modal v-model:visible="visible" title="新增用户信息" @ok="execAdd">
    <a-form
      ref="fromRef"
      :model="addObj"
      :label-col="{ span: 5 }"
      :wrapper-col="{ span: 14 }"
    >
      <a-form-item label="账号">
        <a-input v-model:value="addObj.u_id" />
      </a-form-item>
      <a-form-item label="姓名">
        <a-input v-model:value="addObj.u_name" />
      </a-form-item>
      <a-form-item label="性别">
        <a-radio-group v-model:value="addObj.u_sex">
          <a-radio value="1">男</a-radio>
          <a-radio value="2">女</a-radio>
        </a-radio-group>
      </a-form-item>
      <a-form-item label="出生日期">
        <a-date-picker v-model:value="addObj.u_birth" />
      </a-form-item>
    </a-form>
  </a-modal>
</template>
<script>
//新增
import { ref, reactive } from "vue";
import { post, tip } from "@/common";

export default {
  setup(props, { emit }) {
    const fromRef = ref();
    const addObj = reactive({
      u_id: "",
      u_name: "",
      u_sex: "",
      u_birth:""
    });
    const visible = ref(false);

    const open = () => {
      visible.value = true;
    };

    const execAdd = () => {
      //执行新增
      post("/security/user", addObj).then((res) => {
        emit('ok');
        addObj.u_id="";
        addObj.u_name= "";
        addObj.u_sex = "";
        addObj.u_birth = "";
        visible.value = false;
        tip.success("新增客户成功！");        
      });
    };

    return {
      addObj,
      visible,
      execAdd,
      open,
      fromRef,
    };
  },
};
</script>
<style scoped>
</style>